home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libtext / bump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.4 KB  |  65 lines

  1. /*
  2.  * bump.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * bump.c,v 4.1 1994/08/09 08:02:12 explorer Exp
  17.  *
  18.  * bump.c,v
  19.  * Revision 4.1  1994/08/09  08:02:12  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:14  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:41:39  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #include "texture.h"
  30. #include "bump.h"
  31.  
  32. /*
  33.  * Create and return a reference to a "bump" texture.
  34.  */
  35. Bump *
  36. BumpCreate(size)
  37. Float size;
  38. {
  39.     Bump *bump;
  40.  
  41.     bump = (Bump *)Malloc(sizeof(Bump));
  42.     bump->size = size;
  43.     return bump;
  44. }
  45.  
  46. /*
  47.  * Apply a "bump" texture.
  48.  */
  49. void
  50. BumpApply(bump, prim, ray, pos, norm, gnorm, surf)
  51. Bump *bump;
  52. Geom *prim;
  53. Ray *ray;
  54. Vector *pos, *norm, *gnorm;
  55. Surface *surf;
  56. {
  57.     Vector disp;
  58.  
  59.     DNoise3(pos, &disp);
  60.     norm->x += disp.x * bump->size;
  61.     norm->y += disp.y * bump->size;
  62.     norm->z += disp.z * bump->size;
  63.     (void)VecNormalize(norm);
  64. }
  65.